package com.gs.SynAntiWandering.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.gs.SynAntiWandering.activity.MainActivity;
import com.gs.SynAntiWandering.constant.AllConstants;
import com.gs.SynAntiWandering.util.SPUtil;

public class NotificationReceiver extends BroadcastReceiver {

    public static final String NOTIFY_ACTION = "com.gs.SynAntiWandering.receiver.NotificationReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(NOTIFY_ACTION)) {
            if (SPUtil.getInstance().getString(AllConstants.TOKEN).isEmpty()) {
                return;
            }
            Intent intentGo = new Intent(context, MainActivity.class);
            intentGo.putExtra(AllConstants.WHAT, 2);
            intentGo.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intentGo);
        }
    }
}
